
<div class="uploadWrapper${fieldname}">
   <div class="layui-box layui-upload-button" style="line-height:36px;">
   		<input type="file" class="layui-upload-file" name="file" id="uploadBtn_${fieldname}" >
    </div>
	<input type="hidden" name="${fieldname}" id="${fieldname}" value="${value!''}" />
	<div style="width: 150px; height: 150px; overflow: hidden; ">
		<img id="img_${fieldname}" style="width: 150px; height: 150px;"	<#if !value?? || value==""> src="${ctx}/cms/admin/images/transparent.gif"  <#else> src="${value}" </#if> />
	</div>
	<div style="display: none; float: left; margin: 130px 0 0 5px;"	id="divdelbtn_${fieldname}">
		<a href="javascript:;" id="delBtn_${fieldname}" title="删除此图片">
			<img class="delete" src="${ctx}/cms/admin/images/transparent.gif" />
		</a>
	</div>
</div>

<script>
$(function(){
	layui.use(['form', 'layedit', 'laydate','upload'], function(){
	    var form = layui.form()
	        ,layer = layui.layer
	        ,layedit = layui.layedit
	        ,laydate = layui.laydate;
	    
	    layui.upload({
		    url: '${ctx}/eop/upload/upload-file.do?ajax=1&subFolder=spec'
		    ,elem: '#uploadBtn_${fieldname}' //指定原始元素，默认直接查找class="layui-upload-file"
		    ,method: 'post' //上传接口的http类型
		    ,success: function(res){
		    	$("#img_${fieldname}").attr("src",res.path);
		    	$("#${fieldname}").val(res.path);
		    }
		 });
	});
	$("#delBtn_${fieldname}").click(function(){
		$("#img_${fieldname}").attr("src","images/transparent.gif");
		$("#${fieldname}").val("");
	});
})
</script>


